module(..., package.seeall)

new = function ()
	
	
	
	localGroup = display.newGroup();	
	print("GameLevelSelect");
	local myText = display.newText("Level Selection", 0, 0, native.systemFont, 16)
	myText:setTextColor(255, 255, 255)
	localGroup:insert(myText);
	
	local backButton = display.newImageRect("back.png", 256, 256)
	backButton.id = "back";
	backButton.x = 50;
	backButton.y = 300;
	backButton.xScale = 0.2;
	backButton.yScale = 0.2;
	
	local level1Button = display.newImageRect( "1.png", 48, 48 )
	level1Button.id = "Level1";
	level1Button.x = 10;
	level1Button.y = 50;
	
	local level2Button = display.newImageRect( "2.png", 48, 48 )
	level2Button.id = "Level2";
	level2Button.x = 10;
	level2Button.y = 100;
	
	local level3Button = display.newImageRect( "3.png", 48, 48 )
	level3Button.id = "Level3";
	level3Button.x = 10;
	level3Button.y = 150;
	
	local level4Button = display.newImageRect( "4.png", 48, 48 )
	level4Button.id = "Level4";
	level4Button.x = 10;
	level4Button.y = 200;

	localGroup:insert(level1Button);
	localGroup:insert(backButton);
		
	local function listener(event) 
		if (event.phase == "ended") then
			if (event.target.id == "back") then
				director:changeScene("GameMainScreen", "crossfade");
			end
			director:changeScene("Game" .. event.target.id , "crossfade");
		end
		return true 
	end
 
	level1Button:addEventListener("touch", listener);
	level2Button:addEventListener("touch", listener);
	level3Button:addEventListener("touch", listener);
	level4Button:addEventListener("touch", listener);
	backButton:addEventListener("touch", listener);
	
	return localGroup;	
end